home *** CD-ROM | disk | FTP | other *** search
- #include <intuition/intuition.h>
- #include <intuition/intuitionbase.h>
- #include <devices/timer.h>
- #include <exec/memory.h>
- #include <graphics/gfxbase.h>
- #include <libraries/dosextens.h>
- #include <workbench/startup.h>
- #include <stdio.h>
- #include "defs.h"
- #include "type.h"
- #include "object.h"
- #include "cell.h"
- #include "func.h"
- #include "disp2.h"
- #include "script.h"
-
- #define NUUL_WIDTH 16L
- #define NUUL_HEIGHT 1L
-
- #define IsPal GfxBase->DisplayFlags & PAL
-
- USHORT nuul_data [] = {
- 0x0000, 0x0000,
-
- 0x0000, 0x0000,
-
- 0x0000, 0x0000
- };
-
- int NumPlanes, Mode, Over, Lace;
- int rate = 1;
- long mask = 0;
- struct Screen *dS[2];
- struct Window *dW;
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
- STLPTR Movie = NULL, LoopAddr;
-
- static struct IntuiText r_bd1 = {0, 1, JAM2,10,10, 0L, (UBYTE *)"Insert next disk", NULL };
- static struct IntuiText c_pos = {0, 1, JAM2, 5, 3, 0L, (UBYTE *)"Retry", NULL };
- static struct IntuiText c_neg = {0, 1, JAM2, 5, 3, 0L, (UBYTE *)"Cancel", NULL };
-
- struct timerequest *MyTimer, *CreateTimer ();
-
- extern struct WBStartup *WBenchMsg;
-
- int scene_count;
- int loop_count;
- int action_count;
- int delta_count;
-
- int movie_type;
-
- USHORT *action_buffer;
- USHORT **scene_buffer;
- ULONG *delta_buffer;
- USHORT **loop_stack, **ls_limit;
- USHORT **scene_stack, **ss_limit;
-
- main (argc, argv)
-
- char **argv;
- int argc;
-
- {
- char fn[256];
- char arg[256];
- int Loop, Single;
- struct WBArg *list;
-
- open_first ();
-
- Loop = 1;
- Single = 0;
-
- if (!argc) {
- argc = WBenchMsg->sm_NumArgs;
- list = WBenchMsg->sm_ArgList;
- list++;
- strcpy (fn, list->wa_Name);
- CurrentDir (list->wa_Lock);
- goto parsed;
- }
-
- if (argc < 2) {
- puts ("Usage: play file [+s] [-l]");
- exit (0);
- }
-
- strcpy (fn, *++argv);
- argc--;
-
- while (--argc) {
- strcpy (arg, *++argv);
-
- if (!strcmp ("-l", arg))
- Loop = 0;
-
- if (!strcmp ("+s", arg))
- Single = 1;
- }
-
- parsed: if (!(MyTimer = CreateTimer (UNIT_MICROHZ))) {
- puts ("Couldn't start timer");
- goto aborts;
- }
-
- if (LoadMovie (fn)) {
- (void) PlayMovie (Loop, Single);
- }
- (void) DumpMovie ();
-
- aborts: close_things ();
- }
-
- void SetDS ()
-
- {
- if ((movie_type & 0x40) && Mode == 1) {
- DS.Width = 640;
- if (IsPal)
- DS.Height = 256;
- else
- DS.Height = 200;
-
- DW.Width = DS.Width;
- DW.Height = DS.Height;
-
- DS.Depth = 1;
- DS.ViewModes = HIRES;
- return;
- }
-
- DS.Width = 320 + 32 * Over;
-
- if (IsPal)
- DS.Height = 256 + 26 * Over;
- else
- DS.Height = 200 + 20 * Over;
-
- DS.Depth = Mode;
-
- switch (Mode) {
- case 1:
- case 4:
- DS.Width *= 2;
- DS.ViewModes = HIRES;
- break;
- case 5:
- DS.ViewModes = 0;
- break;
- case 6:
- DS.ViewModes = HAM;
- break;
- }
-
- if (Lace) {
- DS.ViewModes |= LACE;
- DS.Height *= 2;
- }
-
- DW.Width = DS.Width;
- DW.Height = DS.Height;
- }
-
- void DoOver ()
-
- {
- int i;
- SHORT vert, horiz;
- struct ViewPort *v;
-
- if (!Over)
- return;
-
- if (IsPal)
- if (Lace)
- vert = -25;
- else
- vert = -13;
- else
- if (Lace)
- vert = -20;
- else
- vert = -10;
-
- if (Mode == 4)
- horiz = -32;
- else
- horiz = -16;
-
- for (i = 0; i < 2; i++) {
- v = &dS[i]->ViewPort;
- v->DxOffset = horiz;
- v->DyOffset = vert;
- }
-
- RemakeDisplay (); /* Ugh! */
- }
-
- open_first ()
-
- {
- if(!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",0L))) {
- puts("no intuition here!");
- close_things();
- exit(1);
- }
- mask |= INTUITION;
-
- if(!(GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0L))) {
- puts("no graphics library!");
- close_things();
- exit(2);
- }
- mask |= GRAPHICS;
- }
-
-
- open_last ()
-
- {
- if (!(dS[0]=(struct Screen *)OpenScreen(&DS))) {
- puts("no display screen");
- close_things();
- exit(3);
- }
-
- if (!(dS[1]=(struct Screen *)OpenScreen(&DS))) {
- puts("no display screen");
- close_things();
- exit(4);
- }
-
- DW.Screen = dS[1];
- if (!(dW=(struct Window *) OpenWindow(&DW))) {
- puts ("no display window");
- close_things();
- exit(5);
- }
- }
-
- void close_things()
-
- {
- if (dW)
- CloseWindow(dW);
- if (dS[0])
- CloseScreen(dS[0]);
- if (dS[1])
- CloseScreen(dS[1]);
- if (mask & GRAPHICS) CloseLibrary(GfxBase);
- if (mask & INTUITION) {
- OpenWorkBench ();
- CloseLibrary(IntuitionBase);
- }
- }
-
- STLPTR AddStill (st, pl)
-
- STLPTR st;
- int pl;
-
- {
- int i;
- STLPTR node, temp = st;
-
- node = AllocMem ((long) sizeof (STILL), 0L);
- if (node) {
- node->Next = NULL;
- for (i = 0; i < NumPlanes; i++) {
- node->Planes[i] = NULL;
- node->Size[i] = 0;
- }
- if (temp) {
- while (temp->Next)
- temp = temp->Next;
- temp->Next = node;
- }
- }
- return node;
- }
-
- LoadMovie (fn)
-
- char *fn;
-
- {
- char sn[256], title[256];
- long fp, Open (), Read ();
- UBYTE data;
- int i, pl, lace, fr, loop, blop;
- long res, qq;
- STLPTR curr;
- FILE *sp, *fopen ();
-
- (void) DumpMovie ();
- Movie = NULL;
- LoopAddr = NULL;
- loop = -1;
-
- sp = NULL;
- fp = NULL;
-
- sprintf (sn, "%s/script", fn);
-
- if (!(sp = fopen (sn, "r"))) {
- puts("Can't open script");
- return FALSE;
- }
-
- i = 0;
- do {
- if (!(fread (&title[i], 1, 1, sp)))
- goto load_err;
- } while (title[i++] != '\n');
- i--;
-
- if (!(fread (&data, 1, 1, sp)))
- goto load_err;
-
- movie_type = pl = data;
- NumPlanes = pl & 7;
-
- Mode = pl & 7;
- Over = (pl & 16) >> 4;
- Lace = (pl & 8) >> 3;
-
- SetDS ();
- open_last ();
-
- SetAPen (dW->RPort, 1L);
- Move (dW->RPort, 0L, 10L);
- Text (dW->RPort, title, (long) i);
-
- SetPointer (dW, nuul_data, NUUL_HEIGHT, NUUL_WIDTH, 0L, 0L);
-
- if(pl & 0x40)
- return FinishLoad(sp, fn); /* new format */
-
- if (!(fread (&data, 1, 1, sp)))
- goto load_err;
- rate = data;
-
- if (!(fread (&blop, 2, 1, sp)))
- goto load_err;
- fr = blop;
-
- while (fr >= 0) {
- curr = AddStill (Movie);
- if (!curr)
- return FALSE;
- curr->frame = fr;
- if (!Movie) {
- Movie = curr;
- LoopAddr = curr;
- }
-
- sprintf (sn, "%s/ANIM.%d", fn, fr);
-
- for (;;) {
- if (fp = Open (sn, 1005L))
- break;
-
- if (!AutoRequest (dW, &r_bd1, &c_pos, &c_neg, 0L, 0L, 280L, 80L))
- goto load_err;
- }
-
- res = Read (fp, &curr->CMap[0], 64L);
- if (res < 64)
- goto load_err;
-
- for (i = 0; i < NumPlanes; i++) {
- res = Read (fp, &curr->Size[i], 2L);
- if (res < 2)
- goto load_err;
-
- qq = ((long) curr->Size[i] << 1);
-
- if (!(curr->Planes[i] = AllocMem (qq, 0L)))
- goto load_err;
-
- res = Read (fp, curr->Planes[i], qq);
- if (res < qq)
- goto load_err;
- }
- Close (fp);
- fp = NULL;
-
- if (!(fread (&blop, 2, 1, sp)))
- goto load_err;
- fr = blop;
- }
- if (!(fread (&blop, 2, 1, sp)))
- goto load_err;
- loop = blop;
-
- if (loop > -1)
- while (loop--)
- if (LoopAddr)
- LoopAddr = LoopAddr->Next;
-
- fclose (sp);
- return TRUE;
-
- load_err:
- if (sp)
- fclose (sp);
- if (fp)
- Close (fp);
- return FALSE;
- }
-
- void DumpMovie ()
-
- {
- STLPTR temp;
- int i;
-
- while (Movie) {
- temp = Movie;
- Movie = Movie->Next;
- for (i = 0; i < NumPlanes; i++)
- MyFreeMem (temp->Planes[i], 2L * temp->Size[i]);
- MyFreeMem (temp, (long) sizeof (STILL));
- }
-
- MyFreeMem(scene_buffer, 4L * scene_count);
- MyFreeMem(action_buffer, 4L * action_count);
- MyFreeMem(delta_buffer, 8L * delta_count);
- MyFreeMem(scene_stack, 8L * (scene_count + 2));
- MyFreeMem(loop_stack, 8L * (loop_count + 2));
- scene_buffer = NULL;
- action_buffer = NULL;
- delta_buffer = NULL;
- scene_stack = NULL;
- loop_stack = NULL;
- scene_count = 0;
- loop_count = 0;
- action_count = 0;
- delta_count = 0;
- }
-
- void PlayMovie (flag, step)
-
- int flag, step;
-
- {
- int FrmPos, pause, restart;
- long wait;
- char s[6];
- ULONG CLA;
- USHORT COD;
- UBYTE flip;
- STLPTR play;
- struct IntuiMessage *MSG;
-
- DoOver ();
-
- SetRGB4 (&dS[0]->ViewPort, 0L, 0L, 0L, 0L);
- SetDrMd (&dS[0]->RastPort, JAM1);
- SetAPen (&dS[0]->RastPort, 0L);
-
- SetRGB4 (&dS[1]->ViewPort, 0L, 0L, 0L, 0L);
- SetDrMd (&dS[1]->RastPort, JAM1);
- SetAPen (&dS[1]->RastPort, 0L);
-
- if(movie_type & 0x40) {
- NewPlay(flag, step);
- return;
- }
-
- restart = 0;
- flip = 0; /* Even frame */
- play = Movie; /* Beginning of movie */
- if (!flag)
- LoopAddr = NULL;
-
- wait = ((long) rate - 1L) * 16667L;
- if (wait < 0)
- wait = 0;
-
- FrmPos = 0;
-
- while (play) {
- if (restart) {
- restart = 0;
- FrmPos = 0;
- flip = 0;
- play = Movie;
- RectFill (&dS[1]->RastPort, 0L, 0L, DS.Width - 1L, DS.Height - 1L);
- WaitBlit ();
- ScreenToFront (dS[1]);
- }
-
- if (FrmPos < 2) {
- RectFill (&dS[flip]->RastPort, 0L, 0L, DS.Width - 1L, DS.Height - 1L);
- WaitBlit ();
- }
-
- FrmPos++;
-
- if (IntuitionBase->ActiveWindow != dW)
- ActivateWindow (dW);
-
- MyTimer->tr_node.io_Command = TR_ADDREQUEST;
- MyTimer->tr_time.tv_secs = 0;
- MyTimer->tr_time.tv_micro = wait;
-
- if (!step)
- SendIO (MyTimer);
-
- ExpFrame (play, flip);
- LoadRGB4 (&dS[flip]->ViewPort, &play->CMap[0], 32L);
-
- if (!step)
- if (!CheckIO (MyTimer))
- WaitIO (MyTimer);
-
- WaitTOF ();
- ScreenToFront (dS[flip]);
-
- pause = step;
-
- do {
- while (MSG = GetMsg(dW->UserPort)){
- CLA = MSG->Class;
- COD = MSG->Code;
- ReplyMsg(MSG);
- if (CLA == RAWKEY) {
- switch (COD) {
- case 68:
- restart = 1;
- break;
- case 64:
- if (!step)
- step = 1;
- else
- pause = 0;
- break;
- case 11:
- pause = 0;
- step = 0;
- if (rate < 60)
- rate++;
- break;
- case 12:
- pause = 0;
- step = 0;
- if (rate)
- rate--;
- break;
- case 80:
- case 81:
- case 82:
- case 83:
- case 84:
- case 85:
- case 86:
- case 87:
- case 88:
- case 89:
- pause = 0;
- step = 0;
- rate = (COD - 80) * 6;
- break;
- case 69:
- goto stop;
- }
- }
- }
- } while (pause);
-
- wait = ((long) rate - 1L) * 16667L;
- if (wait < 0)
- wait = 0;
-
- flip = 1 - flip;
- play = play->Next;
- if (!play && LoopAddr) { /* If end & loop */
- play = LoopAddr; /* Send it back */
- if (play == Movie)
- FrmPos = 0;
- else
- FrmPos = 2;
- }
- }
-
- stop: DeleteTimer (MyTimer);
-
- }
-
- void ExpFrame (ptr, f)
-
- STLPTR ptr;
- UBYTE f;
-
- {
- struct BitMap *bm;
- UWORD *src, *trg;
- UWORD packet;
- int pl;
-
- bm = &dS[f]->BitMap;
- for (pl = 0; pl < NumPlanes; pl++) {
- src = (UWORD *)ptr->Planes[pl];
- trg = (UWORD *)bm->Planes[pl];
- packet = *src++;
- #asm
- movea.l -8(a5),a0 ;source
- movea.l -12(a5),a1 ;target
- move.w -14(a5),d2 ;packet count
- bmi .1003 ;wow! no changes!
- clr.l d1 ;make this pretty
-
- .1000 move.l (a0)+,d0 ;get source word
- beq .1002 ;possible skip count
-
- .1001 move.l d0,(a1)+ ;put word in target
- dbf d2,.1000 ;more packets
- bra .1003 ;we be jammin'
-
- .1002 move.w (a0)+,d1 ;number of words to skip
- beq .1001 ;oops! really want a zero
- asl.l #2,d1
- adda.l d1,a1 ;adjust target address
- dbf d2,.1000 ;more packets
-
- .1003
- #endasm
- }
- }
-
- void NewExpFrame (ptr, bm)
-
- STLPTR ptr;
- struct BitMap *bm;
-
- {
- UWORD *src, *trg;
- UWORD packet;
- int pl;
-
- for (pl = 0; pl < NumPlanes; pl++) {
- src = (UWORD *) ptr->Planes[pl];
- trg = (UWORD *) bm->Planes[pl];
- packet = *src++;
- #asm
- movea.l -4(a5),a0 ;source
- movea.l -8(a5),a1 ;target
- move.w -10(a5),d2 ;block count
- bmi .1013
-
- .1010 move.w (a0)+,d1 ;get longword count
- adda.l (a0)+,a1 ;add in destination offset
-
- .1011 move.l (a0)+,(a1)+ ;put longwords in target
- dbra d1,.1011 ;loop through block
-
- .1012 dbra d2,.1010 ;loop blocks
-
- .1013
- #endasm
- }
- }
-
- FinishLoad (sp, fn)
-
- FILE *sp;
- char *fn;
-
- {
- char dn[256], sn[256];
- LONG fp = 0;
- int i, j, fr, loop, deln;
- LONG qq, res;
- STLPTR curr;
- USHORT *a, **s;
- ULONG *d;
-
- int scene_cnt;
- int loop_cnt;
- int action_cnt;
- int delta_cnt;
-
- scene_count = 0;
- loop_count = 0;
- action_count = 0;
- delta_count = 0;
-
- if(!fread(&scene_cnt, 2, 1, sp))
- goto load_err;
- if(!fread(&loop_cnt, 2, 1, sp))
- goto load_err;
- if(!fread(&action_cnt, 2, 1, sp))
- goto load_err;
- if(!fread(&delta_cnt, 2, 1, sp))
- goto load_err;
-
- if(!action_cnt || !scene_cnt || !delta_cnt) {
- fclose(sp);
- return FALSE;
- }
-
- action_buffer = (USHORT *)AllocMem(action_cnt * 4L, 0L);
- scene_buffer = (USHORT **)AllocMem(scene_cnt * 4L, 0L);
- delta_buffer = (ULONG *)AllocMem(delta_cnt * 8L, 0L);
- scene_stack = (USHORT **)AllocMem((scene_cnt + 2) * 8L, 0L);
- loop_stack = (USHORT **)AllocMem((loop_cnt + 2) * 8L, 0L);
-
- if(!scene_buffer || !action_buffer || !delta_buffer || !scene_stack || !loop_stack) {
- fclose(sp);
- return FALSE;
- }
- ss_limit = scene_stack + 2 * (scene_cnt + 2);
- ls_limit = loop_stack + 2 * (loop_cnt + 2);
-
- if(fread(action_buffer, 4, action_cnt, sp) != action_cnt)
- goto load_err;
- if(fread(delta_buffer, 8, delta_cnt, sp) != delta_cnt)
- goto load_err;
- fclose (sp);
-
- s = scene_buffer;
- a = action_buffer;
- for(i = 0; i < scene_cnt; i++) {
- *s++ = a;
- while(*a)
- a += 2;
- a += 2;
- }
-
- i = delta_cnt;
- d = delta_buffer;
- deln = 1;
-
- while (deln <= delta_cnt) {
- curr = AddStill (Movie);
- if (!curr) {
- fclose (sp);
- return FALSE;
- }
-
- if (!Movie)
- Movie = curr;
-
- curr->frame = d[1];
-
- sprintf (sn, "%s/ANIM.%d", fn, deln);
-
- for (;;) {
- if (fp = Open (sn, 1005L))
- break;
-
- if (!AutoRequest (dW, &r_bd1, &c_pos, &c_neg, 0L, 0L, 280L, 80L))
- goto load_err;
- }
-
- res = Read (fp, &curr->CMap[0], 64L);
- if (res < 64)
- goto load_err;
-
- for (i = 0; i < NumPlanes; i++) {
- res = Read (fp, &curr->Size[i], 2L);
- if (res < 2)
- goto load_err;
-
- qq = ((long) curr->Size[i] << 1);
-
- if (!(curr->Planes[i] = AllocMem (qq, 0L)))
- goto load_err;
-
- res = Read (fp, curr->Planes[i], qq);
- if (res < qq)
- goto load_err;
- }
- Close (fp);
- fp = NULL;
-
- deln++;
- d += 2;
- }
-
- fclose(sp);
-
- scene_count = scene_cnt;
- loop_count = loop_cnt;
- action_count = action_cnt;
- delta_count = delta_cnt;
-
- return TRUE;
-
- load_err:
- if (sp)
- fclose (sp);
- if (fp)
- Close (fp);
- return FALSE;
- }
-
- recursion_error()
- {
- puts("Error: Infinite recursion");
- }
-
- NewPlay (flag, step)
- int flag, step;
- {
- int pause;
- char s[6];
- long wait;
- ULONG CLA;
- USHORT COD;
- UBYTE flip;
- STLPTR play;
- USHORT *action;
- ULONG *dl;
- USHORT *ap;
- ULONG frame[2];
- int palette_number;
- int palette_num;
- int plocked;
- int plock;
- int front, swap;
- LONG from, toom;
- int i, restart;
- int in_loop, break_loop, break_loop2;
- USHORT **loop_sp;
- USHORT **scene_sp;
- USHORT **lsp, **lsp2;
- USHORT **ssp, **ssp2;
- LONG secs, micros;
- struct IntuiMessage *MSG;
-
- top:
-
- RectFill (&dS[0]->RastPort, 0L, 0L, DS.Width - 1L, DS.Height - 1L);
- RectFill (&dS[1]->RastPort, 0L, 0L, DS.Width - 1L, DS.Height - 1L);
- WaitBlit ();
-
- front = 0; /* Even frame */
- action = (USHORT *)action_buffer; /* Beginning of movie */
- frame[0] = frame[1] = 0; /* current cell #'s */
- plocked = 0; /* palette not locked */
- palette_number = -1; /* no palette yet */
-
- ScreenToFront (dS[0]); /* proper screen in front */
-
- restart = 0;
- pause = 0;
-
- loop_sp = loop_stack;
- scene_sp = scene_stack;
- in_loop = break_loop = break_loop2 = FALSE;
-
- wait = ((long) rate - 1L) * 16667L;
- if (wait < 0)
- wait = 0L;
-
- for(;;) {
- if (IntuitionBase->ActiveWindow != dW)
- ActivateWindow (dW);
-
- MyTimer->tr_node.io_Command = TR_ADDREQUEST;
- MyTimer->tr_time.tv_secs = 0;
- MyTimer->tr_time.tv_micro = wait;
-
- if (!step)
- SendIO (MyTimer);
-
- ap = action;
-
- ssp = scene_sp;
- ssp2 = scene_stack;
- while(ssp2 != scene_sp) {
- if(ssp == ss_limit) {
- recursion_error();
- break;
- }
- *ssp++ = *ssp2++;
- }
-
- lsp = loop_sp;
- lsp2 = loop_stack;
- while(lsp2 != loop_sp) {
- if(lsp == ls_limit) {
- recursion_error();
- break;
- }
- *lsp++ = *lsp2++;
- }
-
- palette_num = palette_number;
- plock = plocked;
-
- for(;;) {
- if(*ap == ACT_EXPAND || *ap == ACT_BLACK)
- break;
- else if(*ap == ACT_SCENE) {
- if(ssp == ss_limit) {
- ap = action;
- break;
- }
- *ssp++ = ap + 2;
- ap = scene_buffer[*(ap + 1)];
- } else if(*ap == ACT_END) {
- if(ssp == scene_sp)
- break;
- ap = *--ssp;
- } else if(*ap == ACT_STARTLOOP) {
- if(lsp == ls_limit) {
- ap = action;
- break;
- }
- *lsp++ = ap;
- *(LONG *)lsp++ = -1L;
- ap += 2;
- } else if(*ap == ACT_ENDLOOP) {
- if(*(LONG *)(lsp - 1) == -1) {
- lsp -= 2;
- ap += 2;
- } else if(*(LONG *)(lsp - 1) == 0xffffL) {
- ap = *(lsp - 2) + 2;
- *(LONG *)(lsp - 1) = -1L;
- in_loop = TRUE;
- } else if(++*(LONG *)(lsp - 1) == *(ap + 1)) {
- lsp -= 2;
- ap += 2;
- } else {
- ap = *(lsp - 2) + 2;
- *(LONG *)(lsp - 1) = -1L;
- }
- } else if(*ap == ACT_LOCK) {
- plock = TRUE;
- palette_num = -1;
- ap += 2;
- } else if(*ap == ACT_FREE) {
- plock = FALSE;
- ap += 2;
- } else
- ap += 2;
- }
-
- if(*ap == ACT_EXPAND) {
- if(!plock || palette_num < 0)
- palette_num = ((movie_type != 0x61) ? *(ap + 1) : 0);
- toom = *(ap + 1) | ((long)palette_num << 16);
- } else if(*ap == ACT_BLACK)
- toom = 0;
- else
- toom = -1;
-
- if(toom < 0 || toom == frame[front])
- swap = FALSE;
- else {
- swap = TRUE;
- front ^= 1;
- }
- if(swap && toom != frame[front]) {
- if(!toom) {
- RectFill (&dS[front]->RastPort, 0L, 0L, DS.Width - 1L, DS.Height - 1L);
- frame[front] = 0;
- } else {
-
- from = frame[front];
-
- play = Movie;
- dl = delta_buffer;
- i = delta_count;
- while(i--) {
- if(*dl == from && *(dl + 1) == toom)
- break;
- dl += 2;
- play = play->Next;
- }
-
- if(play) {
- LoadRGB4 (&dS[front]->ViewPort, &play->CMap[0], 32L);
- NewExpFrame (play, &dS[front]->BitMap);
- frame[front] = toom;
- } else {
- puts("Internal error");
- break;
- }
- }
- }
-
- if (!step)
- if (!CheckIO (MyTimer))
- WaitIO (MyTimer);
-
- nextac: while(*action != ACT_EXPAND && *action != ACT_BLACK) {
- if(*action == ACT_SCENE) {
- if(scene_sp == ss_limit) {
- recursion_error();
- action = NULL;
- break;
- }
- *scene_sp++ = action + 2;
- action = scene_buffer[*(action + 1)];
- } else if(*action == ACT_END) {
- if(scene_sp == scene_stack)
- break;
- action = *--scene_sp;
- } else if(*action == ACT_STARTLOOP) {
- if(loop_sp == ls_limit) {
- recursion_error();
- action = NULL;
- break;
- }
- *loop_sp++ = action;
- *loop_sp++ = 0;
- action += 2;
- } else if(*action == ACT_ENDLOOP) {
- ap = *(loop_sp - 2);
- if(*(action + 1) == 0xffff) {
- if(in_loop && break_loop) {
- in_loop = break_loop = FALSE;
- *(loop_sp - 1) = -1L;
- break_loop2 = TRUE;
- action = ap + 2;
- } else if(break_loop2) {
- break_loop2 = FALSE;
- loop_sp -= 2;
- action += 2;
- } else {
- action = ap + 2;
- *(loop_sp - 1) = 0xffffL;
- }
- } else if(++*(LONG *)(loop_sp - 1) == *(action + 1)) {
- loop_sp -= 2;
- action += 2;
- } else
- action = ap + 2;
- } else if(*action == ACT_RATE) {
- rate = *(action + 1);
- action += 2;
- } else if(*action == ACT_LOCK) {
- plocked = TRUE;
- palette_number = -1;
- action += 2;
- } else if(*action == ACT_FREE) {
- plocked = FALSE;
- action += 2;
- } else
- break;
- }
-
- if(!action || *action == ACT_END)
- break;
-
- if(*action == ACT_EXPAND || *action == ACT_BLACK) {
- if(swap) {
- WaitTOF ();
- ScreenToFront (dS[front]);
- }
- palette_number = palette_num;
- } else if(*action == ACT_PAUSE) {
-
- micros = *(action + 1) * 16667L;
- secs = micros / 1000000L;
- micros = micros % 1000000L;
-
- MyTimer->tr_node.io_Command = TR_ADDREQUEST;
- MyTimer->tr_time.tv_secs = secs;
- MyTimer->tr_time.tv_micro = micros;
-
- if (!step) {
- SendIO (MyTimer);
-
- if (!CheckIO (MyTimer))
- WaitIO (MyTimer);
- }
- } else if(*action == ACT_HOLD) {
- i = 1;
- while(i) {
- Wait(1L << dW->UserPort->mp_SigBit);
- while (MSG = (struct IntuiMessage *) GetMsg(dW->UserPort)){
- CLA = MSG->Class;
- COD = MSG->Code;
- ReplyMsg (MSG);
- if (CLA == RAWKEY && COD == 64)
- i = 0;
- }
- }
- }
-
- pause = step;
-
- do {
- while (MSG = (struct IntuiMessage *)GetMsg(dW->UserPort)){
- CLA = MSG->Class;
- COD = MSG->Code;
- ReplyMsg(MSG);
- if (CLA == RAWKEY) {
- switch (COD) {
- case 68:
- restart = 1;
- break;
- case 51:
- if(in_loop)
- break_loop = TRUE;
- break;
- case 64:
- if (!step)
- step = 1;
- else
- pause = 0;
- break;
- case 11:
- pause = 0;
- step = 0;
- if (rate < 60)
- rate++;
- break;
- case 12:
- pause = 0;
- step = 0;
- if (rate)
- rate--;
- break;
- case 80:
- case 81:
- case 82:
- case 83:
- case 84:
- case 85:
- case 86:
- case 87:
- case 88:
- case 89:
- pause = 0;
- step = 0;
- rate = (COD - 80) * 6;
- break;
- case 69:
- goto stop;
- }
- }
- }
- } while (pause && !restart);
-
- if(restart)
- goto top;
-
- wait = ((long) rate - 1L) * 16667L;
- if (wait < 0)
- wait = 0L;
-
- if(*action != ACT_EXPAND && *action != ACT_BLACK) {
- action += 2;
- goto nextac;
- }
-
- if(*action == ACT_BLACK) {
- RectFill (&dS[front ^ 1]->RastPort, 0L, 0L, DS.Width - 1L, DS.Height - 1L);
- frame[front ^ 1] = 0;
- }
- action += 2;
- }
-
- if (flag)
- goto top;
-
- stop:
- DeleteTimer (MyTimer);
- }
-
- void MyFreeMem(addr, size)
- LONG *addr;
- LONG size;
- {
- if(addr && size)
- FreeMem(addr, size);
- }
-